wayland: Fix initial fullscreen monitor support
authorGiovanni Campagna <gcampagn@cs.stanford.edu>
Sun, 26 Jul 2015 00:22:41 +0000 (17:22 -0700)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 26 Jul 2015 05:55:56 +0000 (01:55 -0400)
-1 means that we have no specific preference for an initial
fullscreen monitor, and -1 is less than the number of monitors,
so we would end up accessing invalid memory. Prevent that.

https://bugzilla.gnome.org/show_bug.cgi?id=752875

gdk/wayland/gdkwindow-wayland.c

index e9d077e00e0c2120db04f045221225d79f9d1b1e..deda19434174508dbd86556ffbd139566cf5b3e2 100644 (file)
@@ -1001,7 +1001,8 @@ gdk_wayland_window_create_xdg_surface (GdkWindow *window)
   const gchar *app_id;
   GdkScreen *screen = gdk_window_get_screen (window);
   struct wl_output *fullscreen_output = NULL;
-  if (impl->initial_fullscreen_monitor < gdk_screen_get_n_monitors (screen))
+  if (impl->initial_fullscreen_monitor >= 0 &&
+      impl->initial_fullscreen_monitor < gdk_screen_get_n_monitors (screen))
       fullscreen_output = _gdk_wayland_screen_get_wl_output (screen, impl->initial_fullscreen_monitor);
 
   impl->xdg_surface = xdg_shell_get_xdg_surface (display_wayland->xdg_shell, impl->surface);